import javax.swing.JFrame;


public class Game {
	
	static GamePanel panel = new GamePanel();
	
	static InputHandler input = new InputHandler();
	
	public static void movePlayer()
	{
		if(input.forward)
		{
			panel.player.movePlayer(0, -3);
		}
		
		if(input.backward)
		{
			panel.player.movePlayer(0, 3);
		}
		
		if(input.left)
		{
			panel.player.movePlayer(3, 0);
		}
		
		if(input.right)
		{
			panel.player.movePlayer(-3, 0);
		}
	}
	
	public static void tick()
	{
		while(true)
		{
			movePlayer();
			
			panel.repaint();
			panel.tick();
			try
			{
				Thread.sleep(20L);
			}catch(Exception e){}
		}
	}
	
	public static void main(String[] args)
	{
		
		
		JFrame gameFrame = new JFrame("Game");
		gameFrame.addKeyListener(input);
		gameFrame.setSize(800, 600);
		gameFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		gameFrame.setResizable(false);
		gameFrame.setLocationRelativeTo(null);
		gameFrame.setVisible(true);
		
		gameFrame.add(panel);
		
		tick();
	}
	
}
